A Tutorial for Those Who are Interested in the Mysteries of Serial Communication
By David K. Merriman
Okay, now that I've gotten that out of my system, let me introduce you to the real world of RS-232C, or what is normally called "Serial Communication".
First, some background. RS-232C breaks down into the following "code":
RS =
@Recommended
Standard
232 = the standard number
C = the revision
It is the RECOMMENDED part of RS232 that causes the vast majority of the problems that people have with these devices. It was initially developed to allow a large number of devices to be able to interfaced with each other with a minimum of hassle- it covered such things as how long the cables could be (50' maximum), voltage levels (+/- 15 volts, depending on logic level), how fast the voltage could change, and a number of other technical specifications (see the Tecnical Specifications table at the end of this document for details). It's primary purpose, though, was to try and establish a standard for the signals that would be used between 2 serial devices. To do this, it was determined to be necessary to divide these serial devices into one of two groups: Data Terminal Equipment (the talkers), and Data Communication Equipment (the listeners), or DTE and DCE. It's easy to remember which is which by thinking of DTE as the Data Talker, and the DCE as the Data Catcher. Since the DCE equipment was considered "passive"; the signal names were assigned from the DTE point of view. Technically, all 25 pins on the connector have been defined; but there are actually only 8 connections/signals that are commonly used. These are (from the DTE point of view!):
@Pin Signal Name (abbreviation) & signal direction relative to DTE
2 Transmit Data (TD) =>
3 Receive Data (RD) <=
4 Request To Send (RTS) =>
5 Clear To Send (CTS) <=
6 Data Set Ready (DSR) <=
7 Signal Ground (SG) <=>
8 Data Carrier Detect (DCD or CAR or CD) <=
20 Data Terminal Ready (DTR) =>
Pins 2 and 3 are the critical pins: they are the ones that actually carry the data; the rest (except for pin 7) are handshaking lines, so that the DTE and DCE equipment can communicate better. Some devices require only that pins 2, 3, and 7 be connected before data can be transferred; others require a full hardware handshaking arrangement. This will be covered further in a moment.
RS232 uses an electronics industry standard connecter, the D-Sub 25, either male (pins) or female (sockets); see the first drawing of the RS232 SCHEM geoPaint drawing. These connectors are normally abbreviated (and referred to) as DB25M or DB25F (or, sometimes DB25P/DB25S); you will sometimes hear this connector (wrongly) referred to as an RS232 connector- it was in existence well before RS232 adopted it.
One of the problems with RS232 is that it pre-supposes that the two devices connected to it will consist of one DTE and one DCE; the problem comes about because it is entirely up to the MANUFACTURER as to whether he wishes to call his device DTE or DCE; and wire it accordingly. This isn't much of a problem when you have the (presumed) equipment of a terminal (DTE) connected to a modem (DCE), but what happens when you're trying to get some other, entirely different, device connected, such as a printer, plotter, or something else? Or if your equipment manufacturer didn't follow the recommendations, and decided that HIS unit was a DTE when it should actually be a DCE, or vice versa? Or if he decided that he didn't particularly need (or want to pay for, or include) the hardware to allow handshaking, but your other equipment is expecting the handshaking?
Most of the problems with RS232 come about because of the DTE/DCE conventions, and the lack of REAL standards in the protocol. For anyone who has ever tried to just connect two RS232
devices together, not have them work, and spent several hours trying to figure out WHY, this is not a small problem! Fortunea
devices together, not have them work, and spent several hours trying to figure out WHY, this is not a small problem! Fortuneately, there are a finite number of things that can actually be wrong with an RS232 connection; and a rational, reasoned approach to making the connections will go a long way toward speeding up the process.
The related signal pairs for RS232 are as follows:
Data lines : TD and RD
Handshaking : RTS and CTS
DSR and DTR
For the handshaking, which ever signal the device is generating should be matched up with the OPPOSITE function on the other device. In other words, TD on one device should go to the RD on the other, RTS to CTS, and DSR to DTR.
Carrier Detect, CD, is something of an anomaly in RS232: it may or may not be generated by a particular DCE device, and a particular DTE device may not function without it. It was meant to allow a DTE device to determine if it was, in fact, connected to a DCE device before it tried to transmit or receive any data. If a particular DTE device requires it, and the DCE device doesn't generate it, this signal is typically tied to the DTR line. You may want to test any particular DTE device, to see if it requires this signal; conversely, if your DTE doesn't seem to work, you might want to try tying this line to the DTR line/pin.
If you KNOW that you have to make your connections between "true" DTE and DCE devices, you can easily put together a Straight Thru cable, as in Figure A of RS232 SCHEM (in this, and other figures in RS232 SCHEM, pin 7 is assumed to already be in place, since it is
@mandatory
for ALL RS232 interconnects).
If time and/or resources are short, you may want to try the Minimum Configuration, shown in Figure B; it doesn't support any hardware handshaking, but some devices don't require it; particularly at slower data rates.
If you're trying to get two devices of the same type (DTE or DCE) to work, you may simply have to switch the connections between pins 2 and 3, at ONE END ONLY, as shown in figure C. This is commonly called a "Null Modem" connection; and as shown in the figure, does NOT support handshaking.
If you have one device that requires handshaking, and the other doesn't, you can use the "bypass" scheme shown in Figure D, in addition to your data lines, to simplifiy your wiring. The bypass wiring shown will work with EITHER device, DTE or DCE, whichever requires the signals.
If you have TWO DTE or DCE devices to interconnect, the wiring shown in Figure E is probably what will be required.
If you have some other "weird" permutation of signals that have to be made, then you should be able to "mix and match" some combination of the wiring systems show in RS232 SCHEM.
If you're absolutely uncertain as to what needs to be done, then you might want to consider the use of a "Break Out Box". This is basically just a small box that goes between the two devices- it should have some lights (L.E.D.s) on it, as well a a few switches. One of the switches should be marked as being able to reverse the connections between pins 2 & 3; the others should work simply to open the connections between the two devices (isolating them from each other). I have included a schematic for a simple, bare-bones box; it is geoPaint document RS232 B.O.B. The best way to use a breakout box is to set it up for a "straight thru" connection, and then open the signal line switches, so that the two devices are isolated. With this done, you can insert the box between the devices, and the lights should show you which device is generating which signals. Once you've got that straight, it should be a fairly simple matter to make the interconnects. Keep in mind that the two devices should send each other "complimentary" signals, according to the groupings listed previously in this document. The box shown in RS232 B.O.B. is the same one that I use for myself; I'm an electronics tech, and often get called on to make a cable for two RS232 devices. Be cautioned that my design is "line powered", so it WILL provide SOME line loading of the signals; this may or may not be important in your application- but for what it's worth, it hasn't been any problem for me, yet, since the current loading is only a few milliamps per signal. I've included a parts list, and some brief
assembly instructions on the box, as geoWrite document B.O.B. TEXT.
I hope that this has helped you understand what RS232C is all about; and that it will give you something of a starting point, the
assembly instructions on the box, as geoWrite document B.O.B. TEXT.
I hope that this has helped you understand what RS232C is all about; and that it will give you something of a starting point, the next time you have to try to connect two supposedly "RS232 standard" devices to each other.
If you have any questions, comments, criticisms, advice, suggestions (keep 'em clean, folks!), please don't hesitate to leave me Email or a message. My CompuServe ID is 72030,661; I usually check in to the different forum I hang out at at least once a week.
<]Dave[> Merriman
Irving, TX
@RS-232C Technical Specification Summary
@Pin Name EIA CCITT DTE---DCE Function
@RS-232C Technical Specification Summary
@Pin Name EIA CCITT DTE---DCE Function
1 CG AA 101 --- Chassis Ground
2 TD BA 103 ---> Transmit Data
3 RD BB 104 <--- Receive Data
4 RTS CA 105 ---> Request to Send
5 CTS CB 107 <--- Clear to Send
6 DSR CC 107 <--- Data Set Ready
7 SG AB 102 --- Signal Ground
8 DCD CF 109 <--- Data Carrier Detect
9 <--- Positive Test Voltage
10 <--- Negative Test Voltage
11 not used
12 SCDC SCF 122 <--- Secondary DCD
13 SCTS SCF 121 <--- Secondary CTS
14 STD SBA 118 ---> Sec. Transmit Data
15 TC DB 114 <--- Transmit Clock
16 SRD SBB 119 <--- Sec. Receive Data
17 RC DD 115 <--- Receive Clock
18 not used
19 SRTS SCA 120 ---> Sec. RTS
20 DTR CD 108.2 <--- Data Terminal Ready
21 SQ CG 110 <--- Signal Quality
22 RI CE 125 <--- Ring Indicator
23 CH 111 ---> Data Rate Selector
24 XTC DA 113 ---> Ext. Transmit Clock
25 ---> Busy
@Electrical Specifications (referenced to SG/Signal Ground)
SPACE +3 to +25 volts ON
MARK -3 to -25 volts OFF
Note that voltage levels are INVERSE of logic values: logic TRUE is voltage NEGATIVE
* Open circuit magnitude shall not exceed 25V, positive or negative
* A line shall be able to withstand a short circuit without damage to itself or the other line; and short circuit currents shall not exceed .5 amps.
* Load impedance for each line shall be less than 7000 ohms.
* Slew Rate : 30V/uS
* Shunt Capacitance : Shall not exceed 2500 pF
* Power off impedance shall be greater than 300 ohms.
* Transition time between Mark and Space shall not exceed 1 mS, or 4% of bit time, whichever is smaller.
* Data transfer rate : rated at 19,200 bits/second or less
* Rated Cable length : 50' or less
* Supports either Synchronous or Asyncronous communications